package com.cmcc.xdr.message;

import java.nio.ByteBuffer;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.cmcc.xdr.entity.AuthenEntity;

public class SingleSigAuthenMsg240 extends SingleSigMsg {

	public AuthenEntity Authen = new AuthenEntity();
	private static SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");

	public SingleSigAuthenMsg240(ByteBuffer buffer,SingleSigGlobalMsg globalMsg) {
		this.setBuffer(buffer);
		this.setSSGMsg(globalMsg);

		Authen.setLength(globalMsg.getTotalLength());
//		Authen.setCity(globalMsg.getCity());
		Authen.setLocalProvince(globalMsg.getLocalProvince());
		Authen.setLocalCity(globalMsg.getLocalCity());
		Authen.setOwnerProvince(globalMsg.getOwnerProvince());
		Authen.setOwnerCity(globalMsg.getOwnerCity());
		Authen.setRoamingType(globalMsg.getRoamingType());
		
		Authen.setInterFace(globalMsg.getInterfaceType());
		Authen.setXdrId(globalMsg.getXdrID());
		Authen.setRat(globalMsg.getRat());
		Authen.setImsi(globalMsg.getImsi());
		Authen.setImei(globalMsg.getImei());
		Authen.setMsisdn(globalMsg.getMsisdn());

		Authen.setProcedureStartTime(new Date(loadLong(8)));
		Authen.setProcedureEndTime(new Date(loadLong(8)));
		Authen.setTransactionType(loadInt(1));
		Authen.setTransactionStatus(loadInt(1));
		Authen.setSourceNeIp(loadIp(16));
		Authen.setSourceNePort(loadInt(2));
		Authen.setDestinationNeIp(loadIp(16));
		Authen.setDestinationNePort(loadInt(2));
		Authen.setResultCode(loadInt(4));
		Authen.setExperimentalResultCode(loadInt(4));
		Authen.setOriginRealm(loadStr(44));
		Authen.setDestinationRealm(loadStr(44));
		Authen.setOriginHost(loadStr(64));
		Authen.setDestinationHost(loadStr(64));
		//2.4.0规范新加字段
		Authen.setDataReference(loadStr(5));
		Authen.setTadsResult(loadInt(1));
		Authen.setSessionId(loadStr(128));
		Authen.setUserEci(loadInt(4));
		Authen.setUserTac(loadInt(2));
		Authen.setInsertDate(format.format(new Date()));

	}

	public AuthenEntity getAuthen() {
		return Authen;
	}

	public void setAuthen(AuthenEntity authen) {
		Authen = authen;
	}

}